//
//  ExpandInfo.m
//  RSW.IOS
//
//  Created by zhaiqiuqiu on 16/12/9.
//  Copyright © 2016年 com.xtion.crm. All rights reserved.
//

#import "ExpandInfo.h"

@implementation FieldDescript

@synthesize optionals = _optionals;

-(id)init
{
    self = [super init];
    
    self.controlType = [XMSNumberInt numberIntWithIntValue:0];
    self.entityRegID = @"";
    self.expandFieldID = @"";
    self.fieldLabel = @"";
    self.fieldLength = [XMSNumberInt numberIntWithIntValue:0];
    self.fieldName = @"";
    self.fieldType = [XMSNumberInt numberIntWithIntValue:1];
    self.isAllowEmpty = [XMSNumberInt numberIntWithIntValue:1];
    self.isReadOnly = [XMSNumberInt numberIntWithIntValue:0];
    self.optional = @"";
    self.order = [XMSNumberInt numberIntWithIntValue:0];
    self.regx = @"";
    self.status = nil;
    self.titleAlignment = NSTextAlignmentRight;
    self.optIsVisible = [XMSNumberInt numberIntWithIntValue:0];
    self.viewIsVisible = [XMSNumberInt numberIntWithIntValue:0];
    
    self.param = [NSMutableDictionary new];
    return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
    [aCoder encodeObject:self.controlType forKey:@"controlType"];
    [aCoder encodeObject:self.entityRegID forKey:@"entityRegID"];
    [aCoder encodeObject:self.expandFieldID forKey:@"expandFieldID"];
    [aCoder encodeObject:self.fieldLabel forKey:@"fieldLabel"];
    [aCoder encodeObject:self.fieldLength forKey:@"fieldLength"];
    [aCoder encodeObject:self.fieldName forKey:@"fieldName"];
    [aCoder encodeObject:self.fieldType forKey:@"fieldType"];
    [aCoder encodeObject:self.isAllowEmpty forKey:@"isAllowEmpty"];
    [aCoder encodeObject:self.isReadOnly forKey:@"isReadOnly"];
    [aCoder encodeObject:self.lineName forKey:@"lineName"];
    [aCoder encodeObject:self.optional forKey:@"optional"];
    [aCoder encodeObject:self.optIsVisible forKey:@"optIsVisible"];
    [aCoder encodeObject:self.order forKey:@"order"];
    [aCoder encodeObject:self.regx forKey:@"regx"];
    [aCoder encodeObject:self.status forKey:@"status"];
    [aCoder encodeObject:self.viewIsVisible forKey:@"viewIsVisible"];
}

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self.controlType = [aDecoder decodeObjectForKey:@"controlType"];
    self.entityRegID = [aDecoder decodeObjectForKey:@"entityRegID"];
    self.expandFieldID = [aDecoder decodeObjectForKey:@"expandFieldID"];
    self.fieldLabel = [aDecoder decodeObjectForKey:@"fieldLabel"];
    self.fieldLength = [aDecoder decodeObjectForKey:@"fieldLength"];
    self.fieldName = [aDecoder decodeObjectForKey:@"fieldName"];
    self.fieldType = [aDecoder decodeObjectForKey:@"fieldType"];
    self.isAllowEmpty = [aDecoder decodeObjectForKey:@"isAllowEmpty"];
    self.isReadOnly = [aDecoder decodeObjectForKey:@"isReadOnly"];
    self.lineName = [aDecoder decodeObjectForKey:@"lineName"];
    self.optional = [aDecoder decodeObjectForKey:@"optional"];
    self.optIsVisible = [aDecoder decodeObjectForKey:@"optIsVisible"];
    self.order = [aDecoder decodeObjectForKey:@"order"];
    self.regx = [aDecoder decodeObjectForKey:@"regx"];
    self.status = [aDecoder decodeObjectForKey:@"status"];
    self.viewIsVisible = [aDecoder decodeObjectForKey:@"viewIsVisible"];
    
    return self;
}

-(void)setOptional:(NSString *)optional
{
    _optional = optional;
    _optionals = nil;
}

-(NSArray*)optionals
{
    if(_optional.length >0 && _optionals.count <=0)
    {
        NSMutableArray *optionals = [[_optional componentsSeparatedByString:SplitCommaString] mutableCopy];
        for(NSString *s in [optionals copy])
        {
            if(s.length <= 0)
                [optionals removeObject:s];
        }
        _optionals = [NSArray arrayWithArray:optionals];
    }
    return _optionals;
}


@end

@implementation ExpandInfo

@end

@implementation SingleSelectInfo

@end
